package com.jing21.learn.basic.api.controller;

import com.jing21.learn.common.learn.ApiResult;
import com.jing21.learn.intf.entity.LearnUser;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Random;

/**
 * Create By zhengjing on 2017/11/14 09:28
 */
@RestController
@Api("服务器信息")
@Validated
public class SystemController {

    @GetMapping("/datetime")
    public ApiResult<LocalDateTime> datetime(){
        return ApiResult.getResult(LocalDateTime.now());
    }

    @PostMapping("/bind")
    public ApiResult<LocalDateTime> bind(@RequestBody LearnUser user){

        return ApiResult.getResult(LocalDateTime.now().plus(new Random().nextInt(100), ChronoUnit.HOURS));
    }
}
